<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<title>登录</title>
	<link rel="stylesheet" href="__STATIC__/pear/css/pear.css" />
	<link rel="stylesheet" href="__CSS__/login.css" />
	<link rel="stylesheet" href="__CSS__/variables.css" />
	<script>if (window.self != window.top) { top.location.reload();}</script>
</head>
<body>
	<div class="login-page" style="background-image: url(__IMG__/login/background.svg)">
		<div class="layui-row">
			<div class="layui-col-sm6 login-bg layui-hide-xs">
				<img class="login-bg-img" src="__IMG__/login/banner.png" alt="" />
			</div>
			<div class="layui-col-sm6 layui-col-xs12 login-form">
				<div class="layui-form">
					<div class="form-center">
						<div class="form-center-box">
							<div class="top-log-title">
								<img class="top-log" src="http://www.layui-vue.com/assets/logo.685dda16.jpg" alt="" />
								<span>Tomato SAAS 1.0</span>
							</div>
							<div class="top-desc">
								免 费 开 源 的 基 础 SaaS 工 具
							</div>
							<div style="margin-top: 30px;">
								<div class="layui-form-item">
									<div class="layui-input-wrap">
										<div class="layui-input-prefix">
											<i class="layui-icon layui-icon-username"></i>
										</div>
										<input lay-verify="required|username" placeholder="账户" name="username" autocomplete="off" class="layui-input">
									</div>
								</div>

								<div class="layui-form-item">
									<div class="layui-input-wrap">
										<div class="layui-input-prefix">
											<i class="layui-icon layui-icon-password"></i>
										</div>
										<input type="password" name="password" value="" class="layui-input" lay-affix="eye"
											lay-verify="required|password" placeholder="密码" autocomplete="off">
									</div>
								</div>
								<input type="text" name="csrf" hidden value="{$captcha}">
								<div class="tab-log-verification">
									<div class="verification-text">
										<div class="layui-input-wrap">
											<div class="layui-input-prefix">
												<i class="layui-icon layui-icon-auz"></i>
											</div>
											<input lay-verify="required|captcha" placeholder="验证码" autocomplete="off" name="captcha" class="layui-input">
										</div>
									</div>
									<img src="/codeimg/{$captcha}" alt="" class="verification-img" />
								</div>
								<div class="layui-form-item">
									<div class="remember-passsword">
										<div class="remember-cehcked">
											<input type="checkbox" name="remember" lay-skin="primary" title="记住我">
										</div>
									</div>
								</div>
								<div class="login-btn">
									<button type="button" lay-submit lay-filter="login" class="layui-btn login">登 录</button>
								</div>
								<div class="other-login">
									<div class="other-login-methods">其他方式</div>
									<div class="greenText">注册账号</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<!-- 资 源 引 入 -->
	<script src="__STATIC__/layui/layui.js"></script>
	<script src="__STATIC__/pear/pear.js"></script>
	<script>
		layui.use(['form', 'button', 'popup','tools'], function () {
			let form = layui.form;
			let button = layui.button;
			let popup = layui.popup,tools=layui.tools;
			console.log(window.location.href)
			form.verify({
				username: function(value, elem){
					if (!new RegExp("^[a-zA-Z0-9_\u4e00-\u9fa5\\s·]+$").test(value)) {
						return '用户名不能有特殊字符';
					}
					if (/(^_)|(__)|(_+$)/.test(value)) {
						return '用户名首尾不能出现下划线';
					}
					if (/^\d+$/.test(value)) {
						return '用户名不能全为数字';
					}
					if (!/^[\S]{6,16}$/.test(value)) {
						return '用户名长度必须大于5';
					}
				},
				password: function(value, elem) {
					if (/^\d+$/.test(value)) {
						return '密码不能全为数字';
					}
					if (!/^[\S]{6,16}$/.test(value)) {
						return '密码必须为 6 到 16 位的非空字符';
					}
				},
				captcha: function(value, elem) {
					if (!new RegExp("^[a-zA-Z0-9\s·]+$").test(value)) {
						return '验证码不能有特殊字符';
					}
					if (value.length !== 4) {
						return '验证码长度错误，请输入为4个字符';
					}

				}
			});
			form.on('submit(login)', function (data) {
				tools.submit(window.location.href,data.field,'post');
				button.load({
					elem: '.login',
					time: 1500,
					done: function () {
						// popup.success("登录成功", function () {
						// 	location.href = "../index.html"
						// });
					}
				})

				return false;
			});
		})
	</script>
</body>
</html>
